<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="content-type" content="text/html;charset=utf-8">

<link rel="stylesheet" href="js/easyui/demo/demo.css" type="text/css"></link>
<link rel="stylesheet" href="js/easyui/themes/icon.css" type="text/css"></link>
<link rel="stylesheet" href="js/easyui/themes/default/easyui.css" type="text/css"></link>

<script type="text/javascript" src="js/easyui/jquery-1.6.min.js"></script>
<script type="text/javascript" src="js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="script/common.js"></script>
<link href="css/style.css" rel="stylesheet" type="text/css">


<style type="text/css">
p>span {
    font-weight: 400;
    font-style: normal;
    font-size: 13px;
    color: #333333;
    text-align: left;
	}


</style>
<script type="text/javascript">
   /**
	*打开产品窗口
	*/
	 function showProductList(){
	 	//点击选择产品去掉提示
	 	$("#product_msg").html("");
	 	//打开窗口
 		$("#productList").window('open');
	 }
 
 	/**
	 * 根据制定页面跳转
	 */
	function bp_reload() {
		var offset = document.getElementById("bp_offset").value;
		var idx = (offset == null) ? 0 : parseInt(offset) - 1;
			
		var trgUrl = 'productgetAllProduct.action?offset=' + idx;
		$('#productList').window('refresh', trgUrl); 
	}

	/**
	 * 根据条件查询
	 */
	function bp_query() {
		var productCd=$("#bp_productCd").val();
		var brad = $("#bp_brad").combobox("getValue");
		var spno=$("#bp_spno").val();
		var jhdt = $("#bp_jhdt").datetimebox('getValue');
		var xjdt = $("#bp_xjdt").datetimebox('getValue');
		
		var trgUrl = 'productgetAllProduct.action?spno='+ spno+'&jhdt='+ jhdt+'&productCd='+ productCd
					+'&xjdt='+ xjdt+'&brad='+ brad;
					
		$('#productList').window('refresh', trgUrl); 
	}
	
	
	/**
	 * 翻到给定偏移量的页面
	 */
	function bp_turnPage(offset){
	
		var productCd=$("#bp_productCd").val();
		var brad = $("#bp_brad").combobox("getValue");
		var spno=$("#bp_spno").val();
		var jhdt = $("#bp_jhdt").datetimebox('getValue');
		var xjdt = $("#bp_xjdt").datetimebox('getValue');
		
		var trgUrl = 'productgetAllProduct.action?spno='+ spno+'&jhdt='+ jhdt+'&productCd='+ productCd
					+'&xjdt='+ xjdt+'&brad='+ brad+ '&offset=' + offset;
					
		$('#productList').window('refresh', trgUrl); 
	}
 
 
 	/**
	 * 选择产品信息
	 * @param index
	 * @param value
	 */
	function chooseBProductP(index,value){ 
		var productCd = value['productCode'].trim();
		
		$("#productList").window('close');
		$("#productCode").textbox('setValue',productCd);//赋值
	}
 
 
   /**
    *返回
    */
    function goBackFavor(url,title){
    
    	var tabbar = window.parent.$('#tabs');
		var tab = tabbar.tabs('getSelected');

		if (tab){
			var index = tabbar.tabs('getTabIndex', tab);
		
			if(url != null){
				addPanelExists(url,title);
				tabbar.tabs('close', index);
			}else{
				tabbar.tabs('close', index);
			}
		}
    }
    
    /**
     *验证
     */
     $(document).ready(function() {
     	var flag_Price=true;
     
     	//验证工艺名称
		$("#price").textbox("textbox").blur(function(){
		$("#price_msg").html("");
		//正则表达式整数为10位数字，小数为2位数字
		var regular_stdPrice = /^(0|[1-9]\d*)(\.\d{0,2})?$/;
		
		var src=$("#price").val();

		//补全到小数点后两位
		var rs = src.indexOf('.');    
	        if (rs < 0) {    
	            rs = src.length;    
	            src += '.';    
	        }    
	    while (src.length <= rs + 2) {    
	    	src += '0';    
	        }    

	    var stdPrice=src;
	    //赋值
		$('#price').textbox('initValue', stdPrice);
		
		if(stdPrice==''){
			$("#price_msg").html("");
			flag_Price=true;
		}else if(regular_stdPrice.test(stdPrice)){
			$("#price_msg").html("");
			flag_Price = true;
		}else{
			$("#price_msg").append("<font color='red'>*必须为两位小数的正数</font>");
			flag_Price = false;
		}
		
		});
		
		
		//保存
		$("#save").click(function() {
		
			if(flag_Price){
			
				$("#saveform").submit();
			
				return true;
			
			} else {
			
				return false;
			
			}
		
		});
     
     })
     
</script>
<body>
	<div style="display: none;">
		<!-- 产品信息  -->
		<div id="productList" class="easyui-window"  title="产品信息" collapsible="false"  minimizable="false"  maximizable="false" closed="true"  modal="true"
			 style="width:800px;height:540px; padding: 10px;" href="productgetAllProduct.action"> 
		</div>  
	</div>
	<div >
		<form action="cpaddCostcheckProduct" id="saveform" method="post">
				<div>
					<h3 class="tab-subtitle"></h3>
				</div>
				
					<table class="form-table">
						<tr>
							<td>产品编码</td>
							<td>
							 <input class="easyui-textbox" id="productCode" name="costcheckProduct.productCode" value="" style="width: 105px; height: 26px;" readonly="true" /> 
				             <input class="easyui-linkbutton" type="button" id="query" style="border-color: #95B8E7; color: #95B8E7" onclick="showProductList()" value="…">
							 <span style="color: red;" id="product_msg"></span>
							</td>
						</tr>
						<tr>
							<td>价格</td>
							<td>
								<input class="easyui-textbox" id="price" name="costcheckProduct.price" style="width:148px;height:26px;"/>
								<span style="color: red;" id="price_msg"></span>
							</td>
						</tr>
						<tr>
							<td>备注</td>
							<td>
								<input class="easyui-textbox" id="memo" name="costcheckProduct.memo" style="width:148px;height:80px;"/>
								<span style="color: red;" id="fvrDesc_msg"></span>
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<input id="save" class="easyui-linkbutton" type="button" value="保存" />&nbsp;&nbsp;
								<input class="easyui-linkbutton" type="button" onclick="goBackFavor()" value="返回" />
							</td>
						</tr>
					</table>
		</form>
	</div>
</body>
</html>